402A - Nuts - CodeForces Solution


greedy math *1100

Please click on ads to support us..

Python Code:

import collections
import heapq
import sys
import math
import itertools
import bisect
from io import BytesIO, IOBase
import os


def values(): return tuple(map(int, sys.stdin.readline().split()))


def inlst(): return [int(i) for i in sys.stdin.readline().split()]



def inp(): return int(sys.stdin.readline())


def inpstr(): return sys.stdin.readline().strip()


def words(): return [i for i in sys.stdin.readline().split()]


def chars(): return list(sys.stdin.readline().strip())


def solve():
    k,nut,b,v=values()
    req=math.ceil(nut/v)
    now=0
    tot=0
    while b>0 and now <req:
        m=min(k,b+1)
        now+=m
        b-=m-1
        tot+=1
            if now>=req:print(tot)
    else:
        print(tot+req-now)

if __name__ == "__main__":
                solve()


Comments

Submit
0 Comments
More Questions

1523B - Lord of the Values
1406C - Link Cut Centroids
2409. Count Days Spent Together
2410. Maximum Matching of Players With Trainers
1604C - Di-visible Confusion
997A - Convert to Ones
218A - Mountain Scenery
486B - OR in Matrix
1405A - Permutation Forgery
1733A - Consecutive Sum
1733B - Rule of League
1733C - Parity Shuffle Sorting
1264A - Beautiful Regional Contest
1695A - Subrectangle Guess
467B - Fedor and New Game
252C - Points on Line
735C - Tennis Championship
992A - Nastya and an Array
554A - Kyoya and Photobooks
79B - Colorful Field
265B - Roadside Trees (Simplified Edition)
1362C - Johnny and Another Rating Drop
1214C - Bad Sequence
1091B - New Year and the Treasure Geolocation
244A - Dividing Orange
1061C - Multiplicity
1312A - Two Regular Polygons
801A - Vicious Keyboard
510B - Fox And Two Dots
616D - Longest k-Good Segment